package com.netintech.project.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.netintech.core.aspectj.lang.annotation.Log;
import com.netintech.core.aspectj.lang.enums.BusinessType;
import com.netintech.project.system.domain.Test;
import com.netintech.project.system.service.TestService;
import com.netintech.core.web.controller.BaseController;
import com.netintech.core.web.domain.RequestResult;
import com.netintech.common.utils.poi.ExcelUtil;
import com.netintech.core.web.page.TableDataInfo;

/**
 * 测试功能Controller
 * 
 * @author admin
 * @date 2020-05-20
 */
@RestController
@RequestMapping("/system/test")
public class SysTestController extends BaseController
{
    @Autowired
    private TestService testService;

    /**
     * 查询测试功能列表
     */
    @PreAuthorize("@ss.hasPermi('system:test:list')")
    @GetMapping("/list")
    public TableDataInfo list(Test test)
    {
        setPageParam();
        List<Test> list = testService.selectTestList(test);
        return getDataTable(list);
    }

    /**
     * 导出测试功能列表
     */
    @PreAuthorize("@ss.hasPermi('system:test:export')")
    @Log(title = "测试功能", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public RequestResult export(Test test)
    {
        List<Test> list = testService.selectTestList(test);
        ExcelUtil<Test> util = new ExcelUtil<Test>(Test.class);
        return util.exportExcel(list, "test");
    }

    /**
     * 获取测试功能详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:test:query')")
    @GetMapping(value = "/{id}")
    public RequestResult getInfo(@PathVariable("id") Long id)
    {
        return RequestResult.success(testService.selectTestById(id));
    }

    /**
     * 新增测试功能
     */
    @PreAuthorize("@ss.hasPermi('system:test:add')")
    @Log(title = "测试功能", businessType = BusinessType.INSERT)
    @PostMapping
    public RequestResult add(@RequestBody Test test)
    {
        return returnResult(testService.insertTest(test));
    }

    /**
     * 修改测试功能
     */
    @PreAuthorize("@ss.hasPermi('system:test:edit')")
    @Log(title = "测试功能", businessType = BusinessType.UPDATE)
    @PutMapping
    public RequestResult edit(@RequestBody Test test)
    {
        return returnResult(testService.updateTest(test));
    }

    /**
     * 删除测试功能
     */
    @PreAuthorize("@ss.hasPermi('system:test:remove')")
    @Log(title = "测试功能", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public RequestResult remove(@PathVariable Long[] ids)
    {
        return returnResult(testService.deleteTestByIds(ids));
    }
}
